//
//  UIViewController+SKNoDataView.m
//  skhr
//
//  Created by sujeking on 2018/6/22.
//  Copyright © 2018年 sujeking. All rights reserved.
//

#import "UIViewController+SKNoDataView.h"
#import <objc/runtime.h>
#import "generalToolBox.h"

@implementation UIViewController (SKNoDataView)


- (void)setNoDataView:(UIView *)noDataView {
  objc_setAssociatedObject(self, "noDataView", noDataView, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (UIView *)noDataView {
  return objc_getAssociatedObject(self, "noDataView");
}

- (void)setNodataTapAction:(void (^)(void))nodataTapAction {
  objc_setAssociatedObject(self, "ndtap", nodataTapAction, OBJC_ASSOCIATION_COPY_NONATOMIC);
}

- (void (^)(void))nodataTapAction {
  return objc_getAssociatedObject(self, "ndtap");
}

- (UIView *)noDataViewWithTableView:(UITableView *)tableView tipMsg:(NSString *)msg {
  UIView *noDataView = [[UIView alloc] initWithFrame:tableView.bounds];
  UIImageView *imv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"list_nodata"]];
  imv.frame = CGRectMake(0, 0, 250, 200);
  imv.center = noDataView.center;
  [noDataView addSubview:imv];
  
  
  
  
  
  UILabel *label = [UILabel new];
  label.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
  label.textColor = [generalToolBox getColorWithHexadecimalColorStr:@"0x6B7897"];
  label.text = msg;
  label.numberOfLines = 0;
  label.textAlignment = NSTextAlignmentCenter;
  label.frame = CGRectMake(50, CGRectGetMaxY(imv.frame) + 10, CGRectGetWidth(noDataView.bounds) - 100, 30);
  [noDataView addSubview:label];
  
  self.noDataView = noDataView;
  return noDataView;
}

@end
